import Vue from 'vue'
import Vuex from 'vuex'
// import createLogger from 'vuex/dist/logger'

import * as getters from './getters'
import * as actions from './actions'
import state from './state'
import mutations from './mutations'
// import createPersistedState from 'vuex-persistedstate'

const debug = process.env.NODE_ENV !== 'production'

Vue.use(Vuex)
// 引入vuex-persistedstate，将vuex的数据持久化到本地
// 小程序编译报错 放弃使用
export default new Vuex.Store({
  state,
  mutations,
  getters,
  actions,
  strict: debug
  // plugins: [
  //   debug ? [createLogger()] : [],
  //   createPersistedState({
  //     storage: {
  //       getItem: key => wx.getStorageSync(key),
  //       setItem: (key, data) => wx.setStorageSync(key, data),
  //       removeItem: key => {}
  //     }
  //   })
  // ]
})
